import { createRouter, createWebHashHistory } from 'vue-router'
import Login from '@/pages/admin/login.vue'

import Index from '@/pages/frontend/index.vue'
import AdminIndex from '@/pages/admin/index.vue'
import Admin from '@/layouts/admin/admin.vue'

// 声明所有路由
const routes = [
  {
    path: '/',
    component: Index,
    meta: {
      title: 'kuporo-blog首页'
    }
  },
  {
    path: '/login',
    component: Login,
    meta: {
      title: 'kuporo-blog登录页'
    }
  },
  {
    path: '/admin', // 后台首页
    component: Admin,
    children: [
      {
        path: '/admin/index',
        component: AdminIndex, // 主页内容区域,具体需要渲染的页面
        meta: {
          title: '仪表盘'
        }
      },
      {
        path: '/admin/article/list',
        component: () => import('@/pages/admin/article-list.vue'),
        meta: {
          title: '文章管理'
        }
      },
      {
        path: '/admin/category/list',
        component: () => import('@/pages/admin/category-list.vue'),
        meta: {
          title: '文章管理'
        }
      },
      {
        path: '/admin/tag/list',
        component: () => import('@/pages/admin/tag-list.vue'),
        meta: {
          title: '标签管理'
        }
      },
      {
        path: '/admin/blog/setting',
        component: () => import('@/pages/admin/blog-setting.vue'),
        meta: {
          title: '博客设置'
        }
      }
    ]
  }
]

// 创建路由
const router = createRouter({
  // 指定路由的历史管理方式，hash 模式指的是 URL 的路径是通过 hash 符号（#）进行标识
  history: createWebHashHistory(),
  routes
})

export default router
